using IQIGame.Onigao.GamePlay;

namespace IQIGame.Onigao.Logic
{
    public class LevelReleaseOccupationDelayAction : LgLevelDelayActionBase
    {
        //一个玩家一次只能有一个占用，如果是系统触发的占用实体服务，则理论上可能会有很多
        public override uint MaxStore => 50;

        private EntityOccupationStatus _occupationStatus;

        public void Initialize(LevelPlayer player, LevelEntity entity, int delayFrame, EntityOccupationStatus occupationStatus)
        {
            base.Init(player, entity, delayFrame);
            this._occupationStatus = occupationStatus;
        }

        public override void OnExecute()
        {
            player?.entity.EndOccupationAction(player, _occupationStatus);
            entity.EndOccupationAction(player, _occupationStatus);
            if (_occupationStatus == EntityOccupationStatus.CameraMotion)
            {
                //相机动画模式会保证player一定不为空
                player.isTakenOverBySystem = false;
            }
        }

        public override void OnReset()
        {
            base.OnReset();
            _occupationStatus = EntityOccupationStatus.None;
        }
    }
}
